package entities;

// Generated Aug 20, 2014 12:14:50 PM by Hibernate Tools 3.4.0.CR1

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * ChiTietHoaDon generated by hbm2java
 */
@Entity
@Table(name = "ChiTietHoaDon", catalog = "DemoHibernate")
public class ChiTietHoaDon implements java.io.Serializable {

	private int mahoadon;
	private SanPham sanPham;
	private HoaDon hoaDon;
	private int gia;
	private int soluong;

	public ChiTietHoaDon() {
	}

	public ChiTietHoaDon(SanPham sanPham, HoaDon hoaDon, int gia, int soluong) {
		this.sanPham = sanPham;
		this.hoaDon = hoaDon;
		this.gia = gia;
		this.soluong = soluong;
	}

	@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "hoaDon"))
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "mahoadon", unique = true, nullable = false)
	public int getMahoadon() {
		return this.mahoadon;
	}

	public void setMahoadon(int mahoadon) {
		this.mahoadon = mahoadon;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "masanpham", nullable = false)
	public SanPham getSanPham() {
		return this.sanPham;
	}

	public void setSanPham(SanPham sanPham) {
		this.sanPham = sanPham;
	}

	@OneToOne(fetch = FetchType.LAZY)
	@PrimaryKeyJoinColumn
	public HoaDon getHoaDon() {
		return this.hoaDon;
	}

	public void setHoaDon(HoaDon hoaDon) {
		this.hoaDon = hoaDon;
	}

	@Column(name = "gia", nullable = false)
	public int getGia() {
		return this.gia;
	}

	public void setGia(int gia) {
		this.gia = gia;
	}

	@Column(name = "soluong", nullable = false)
	public int getSoluong() {
		return this.soluong;
	}

	public void setSoluong(int soluong) {
		this.soluong = soluong;
	}

}
